package comman.duke 
{
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.geom.Point;
	/**
	 * ...
	 * @author jerry.d
	 */
	public class GameVars 
	{
		//Game Version
		public static var Version:String;
		//Global Stage
		public static var STAGE:Stage;
		//Global Stage Width
		public static var Stage_Width:int;
		//Global Stage Height
		public static var Stage_Height:int;
		//Debug Level:use with GameUtil.log
		public static var DEBUG_LEVEL:int;
		//Server Address:used for server
		public static var SERVER_ADDRESS:String;
		//Same as below
		public static var SERVER_PORT:int;
		
		public static const ONE_MINUTES:uint = 60 * 1000;
		public static const FIVE_MINUTES:uint = 5 * 60 * 1000;
		public static const TEN_MINUTES:uint = 10 * 60 * 1000;
		
		/** 每一角度对应的弧度 **/
		public static const RADIUS_PER_DEGREE:Number = Math.PI / 180;
		/** 每一弧度对应的角度 **/
		public static const DEGREE_PER_RADIUS:Number = 180 / Math.PI;
		
		public static var Raw_Point:Point = new Point(0,0);
		
		public static var Refer_Date:Date = new Date();
		/** 全局半透明遮罩 **/
		private static var Gray_Mask:Sprite;
		private static function get Mask():Sprite{
			if ( Gray_Mask == null ){
				Gray_Mask = new Sprite();
				RedrawMask();
			}else if ( Gray_Mask.width != Stage_Width || Gray_Mask.height != Stage_Height){
				RedrawMask();
			}
			return Gray_Mask;
		}
		
		public static function RedrawMask():void{
			if ( Gray_Mask != null ){
				var graphics:Graphics = Gray_Mask.graphics;
				graphics.clear();
				graphics.beginFill(0, 0.6);
				graphics.drawRect(0, 0, GameVars.Stage_Width, GameVars.Stage_Height);
				graphics.endFill();
			}
		}
		
		public static function ShowMask():void{
			var mask:Sprite = Mask;
			STAGE.addChild(mask);
		}
		
		public static function HideMask():void{
			var mask:Sprite = Mask;
			if ( STAGE.contains(mask)){
				STAGE.removeChild(mask)
			}
		}
	}

}